import 'package:flutter/material.dart';
import 'package:flutterlib/common/datacenter/user_center.dart';
import 'package:flutterlib/common/net/dao_result.dart';
import 'package:flutterlib/common/net/retrofit/interest_api.dart';
import 'package:flutterlib/common/utils/utils.dart';
import 'package:flutterlib/pages/interest/list/interest_list_widget_page.dart';
import 'package:flutterlib/widgets/bussiness/post/interest_list_item.dart';

///type = 0 获取我的或者是传入userid的兴趣
///type = 1 获取全部兴趣
class InterestSimpleListWidgetPage extends InterestListWidgetPage {
  final int userId;

  InterestSimpleListWidgetPage({Key key, this.userId}) : super(key: key);

  @override
  InterestSimpleListWidgetPageState createState() =>
      InterestSimpleListWidgetPageState();
}

///页面 KeepAlive ，同时支持 动画Ticker
class InterestSimpleListWidgetPageState
    extends InterestListWidgetPageState<InterestSimpleListWidgetPage> {
  getDataLogic(int page) async {
    print(page);

    var interests = await InterestApi.builder()
        .getMyInterests(widget.userId ?? currentUserId);
    return new DataResult(interests, true);
  }

  Widget renderItem(index, interest) {
    return InterestListItem(interest, onPressed: () {
      NavigatorUtils.gotoInterestDetail(context, interest.id);
    });
  }
}
